package com.imooc.ecommerce.conf;

import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * 开启服务之间的调用保护,需要给RestTemplate做一些包装
 * @author zhangshao
 * @since 2023/12/6 23:02
 */
@Slf4j
@Configuration
public class SentinelConfig {

    /**
     * 包装restTemplate
     */
    @Bean
//    @SentinelRestTemplate(fallback = "handleFallback",fallbackClass = RestTemplateExceptionUtil.class,blockHandler = "handleBlock",blockHandlerClass = RestTemplateExceptionUtil.class)
    public RestTemplate restTemplate(){
        // 可以对其做一些业务相关的配置
        return new RestTemplate();
    }








}
